﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using V = Science.Mathematics.VectorCalculus;

namespace VectorCalculus5Ed.Chapter2.Section6
{
    public class Example07
    {
        public Example07()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
        public void Compute()
        {
            V.Function.ToLastType<double[], double> f
                = new V.Function.ToLastType<double[], double>(func);
            double[] at = { 0.0, 0.0, 1.0};
            V.Gradient delf = new V.Gradient(f, at);
            delf.Compute();
            V.Vector v = new V.Vector(delf.Result);
            V.UnitVector n = new V.UnitVector(v);
            result += n[0].ToString() + "  ";
            result += n[1].ToString() + "  ";
            result += n[2].ToString() + "\r\n";
            result += (1.0/Math.Sqrt(2.0)).ToString() + "\r\n";
        }
        private double func(double[] x)
        {
            return x[0] * x[0] * x[1] * x[1] + x[1] + 1.0 - x[2];
        }
    }
}
// 0  0.707106781186548  -0.707106781186548
// 0.707106781186547